package com.example.sangong.myenum;

import com.example.sangong.entity.Score;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@AllArgsConstructor
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)

public enum ScoreEnum {


    ZERO("零点", 0,1),
    ONE("一点", 1,1),
    TWO("两点", 2,1),
    THREE("三点", 3,1),
    FOUR("四点", 4,1),
    FIVE("五点", 5,1),
    SIX("六点", 6,1),
    SEVEN("七点", 7,1),
    EIGHT("八点", 8,2),
    NINE("九点", 9,3),
    SAN_GONG("三公", 10,4),
    THREE_HEAD("三头", 11,5),
    TWO_KING("双王", 12,6),
    THREE_KING("三王", 13,10),
    ;
    /**
     * 成绩名称
     */
    private String name;


    /**
     * 点数
     */
    private int points;
    /**
     * 成绩倍数
     */
    private int multiple;


    private static Map<Integer,ScoreEnum> pointsMap=new HashMap();
    static {
        ScoreEnum[] values = ScoreEnum.values();
        for (ScoreEnum value : values) {
            pointsMap.put(value.getPoints(), value);
        }
    }
    public  static ScoreEnum getScore(int points){
        return pointsMap.get(points);
    }

}
